package net.yambal.RTM.Utilty
{
	import net.yambal.RTM.Method.Timelines;
	import net.yambal.RTM.Event.TimelineEvent;
	
	public class RTMTimelineGetter
	{
		
		private var _cb:Function;
		private var _relay_obj:Object;
		
		public function RTMTimelineGetter()
		{
		}
		
		public function getTimeline(api_key:String, shared_secret:String, token:String, cb:Function, relay_obj:Object = null):void{
			this._cb = cb;
			this._relay_obj = relay_obj;
			
			var tl:Timelines = new Timelines();
			tl.addEventListener(TimelineEvent.CREATE, this.onCreate);
			tl.create(api_key, shared_secret, token);
		}
		
		private function onCreate(e:TimelineEvent):void{
			var tl:Timelines = e.currentTarget as Timelines;
			tl.removeEventListener(TimelineEvent.CREATE, this.onCreate);
			this._cb(e, this._relay_obj);
		}

	}
}